{{extend './_layouts/home.html'}}

{{block 'title'}}{{'多人博客 - 首页'}}{{/block}}

{{block 'body'}}
<section class="container">
  <ul class="media-list">
    {{each topics topic}}
    <li class="media">
      <div class="media-left">
        <a href="#">
            <img width="40" height="40" class="media-object" src="{{topic.user_avatar}}" alt="...">
        </a>
      </div>
      <div class="media-body">
        <h4 class="media-heading"><a href="{{'/topic/'+topic._id}}">{{ topic.title}}</a> &nbsp;&nbsp;&nbsp;&nbsp;<small>作者: {{topic.user_name}}</small> </h4>
        <p>{{ (topic.topic).substr(0,100) + '......' }}</p>
      </div>
    </li>
    {{/each}}

  </ul>
  <nav aria-label="Page navigation">
    <ul class="pagination">
      <li>
        <a href="{{nowPage > 1 ? '/?skip='+ (nowPage-1):'/?skip=1'}}" aria-label="Previous">
        <span aria-hidden="true">&laquo;</span>
      </a>
      </li>
      <!-- <li class="active"><a href="#">1</a></li> -->
      {{each totalPage page}}
      <li class="{{page === nowPage ? 'active':''}}"><a href="/?skip={{page}}" >{{page}}</a></li>
      {{/each}}
      <!-- <li><a href="#">3</a></li>
      <li><a href="#">4</a></li>
      <li><a href="#">5</a></li> -->
      <li>
        <a href="{{nowPage < totalPage.length ? '/?skip='+ (nowPage+1):'/?skip='+(totalPage.length)}}" aria-label="Next">
        <span aria-hidden="true">&raquo;</span>
      </a>
      </li>
    </ul>
  </nav>
</section>
{{/block}}
